import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  overview: ['crm:homePage:read'], // 概况
  dashboard: ['chart:departEdit:read'], // 统计图表
  total: ['total:report:', 'total:financereport:', 'total:brandreport:', 'total:mediumreport:'], // 统计报表
  salesPerformance: ['crm:sales:read'], // 销售业绩
  fileList: ['brand:fileList:read'], // 经营平台
  userList: ['brand:account:read'], // 员工列表
  account: ['brand:accountCodeList:read'] // 账号列表
};
let pageAllAuth = [];
for (const key in authData) {
  // 暂时只展示首页（原统计图表）、统计报表
  if (key === 'dashboard' || key === 'total') {
    pageAllAuth = pageAllAuth.concat(authData[key]);
  }
}

// 首页
const IndexRouter = [{
  path: '/homePage',
  component: Layout,
  redirect: '/homePage/index',
  name: 'homePage',
  meta: { title: '首页', icon: 'sidebar-home', authControl: pageAllAuth },
  children: [{
    path: 'index',
    name: 'dashboard',
    component: () => import('@/views/total/dashboard/index'),
    meta: { title: '首页', headerBarShow: false, authControl: authData.dashboard }
  }, {
    path: 'totalindex',
    name: 'total',
    component: () => import('@/views/total/reportManage/index'),
    meta: { title: '统计报表', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.total } // headerBarShow 为true显示头像
  },
  // 以下4个页面暂时隐藏
  {
    path: 'salesPerformance',
    name: 'salesPerformance',
    hidden: true,
    component: () => import('@/views/salesPerformance/index'),
    meta: { title: '销售业绩', authControl: authData.salesPerformance, priority: true, isSeal: false, headerBarShow: true, mt: 2 } // headerBarShow 为true显示头像
  },
  {
    path: 'list',
    hidden: true,
    name: 'fileList',
    component: () => import('@/views/brand/file/index'),
    meta: { title: '经营平台', priority: true, headerBarShow: true, mt: 2, authControl: authData.fileList }
  },
  {
    path: 'userList',
    name: 'userList',
    hidden: true,
    component: () => import('@/views/brand/userList/index'),
    meta: { title: '员工列表', authControl: authData.userList, priority: true, isSeal: false, keepAlive: false, isChange: true, headerBarShow: true, mt: 2 }
  },
  {
    path: 'account',
    name: 'account',
    hidden: true,
    component: () => import('@/views/brand/account/index'),
    meta: { title: '账号列表', authControl: authData.account, priority: true, headerBarShow: true, mt: 2 }
  },
  /**
   * 内页
   **/
  {
    path: 'createChart',
    name: 'createChart',
    hidden: true,
    component: () => import('@/views/total/chartCreat/create'),
    meta: { title: '创建图表', headerBarShow: true, activeMenu: '/homePage/index' } // headerBarShow 为true显示头像
  },
  {
    path: 'editChart/:id',
    name: 'editChart',
    hidden: true,
    component: () => import('@/views/total/chartCreat/create'),
    meta: { title: '编辑图表', headerBarShow: true, activeMenu: '/homePage/index' } // headerBarShow 为true显示头像
  },
  {
    path: 'totalTabelData/:fileId',
    name: 'totalTabelData',
    component: () => import('@/views/total/reportManage/data'),
    hidden: true,
    meta: { title: '表格数据展示', headerBarShow: true, activeMenu: '/homePage/totalindex' } // headerBarShow 为true显示头像
  },
  {
    path: 'createbase',
    name: 'createBaseReport',
    component: () => import('@/views/total/reportManage/create/baseReport'),
    hidden: true,
    meta: { title: '报表管理', headerBarShow: true, activeMenu: '/homePage/totalindex' } // headerBarShow 为true显示头像
  },
  {
    path: 'editbase/:id',
    name: 'editBaseReport',
    component: () => import('@/views/total/reportManage/create/baseReport'),
    hidden: true,
    meta: { title: '报表管理', headerBarShow: true, activeMenu: '/homePage/totalindex' } // headerBarShow 为true显示头像
  },
  {
    path: 'createcollect',
    name: 'createCollectReport',
    component: () => import('@/views/total/reportManage/create/collectReport'),
    hidden: true,
    meta: { title: '报表管理', headerBarShow: true, activeMenu: '/homePage/totalindex' } // headerBarShow 为true显示头像
  },
  {
    path: 'editcollect/:id',
    name: 'editCollectReport',
    component: () => import('@/views/total/reportManage/create/collectReport'),
    hidden: true,
    meta: { title: '报表管理', headerBarShow: true, activeMenu: '/homePage/totalindex' } // headerBarShow 为true显示头像
  },
  /** 经营平台内页 */
  {
    path: 'data/:fileId',
    name: 'fileData',
    component: () => import('@/views/brand/file/data'),
    meta: { title: '表格数据', priority: true, isSeal: false, headerBarShow: true, activeMenu: '/homePage/list' },
    hidden: true
  },
  {
    path: 'editRole/:roleId',
    component: () => import('@/views/brand/userList/create/index'),
    name: 'editRole',
    meta: { title: '权限编辑', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/homePage/userList' },
    hidden: true
  }]
}];

export default IndexRouter;
